package com.zdsoft.blp.zongbuju.shouye.bianmin.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.squareup.picasso.Picasso;
import com.zdsoft.blp.R;
import com.zdsoft.blp.zongbuju.shouye.bianmin.entity.SheQu;
import com.zdsoft.blp.zongbuju.shouye.linliquan.entity.LinLi;

import java.util.List;

/**
 * Created by Administrator on 2016/8/30.
 */
public class BMsqhdAdapter extends BaseAdapter {
    private List<SheQu> list;
    private LayoutInflater inflater;
    private Context context;

    public BMsqhdAdapter(Context context, List list) {
        inflater = LayoutInflater.from(context);
        this.list = list;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        if(convertView == null){
            convertView = inflater.inflate(R.layout.bianmin_sqhd_item,null);
            holder = new ViewHolder();
            holder.iv_sqhd = (ImageView) convertView.findViewById(R.id.iv_sqhd);
            holder.tv_sqhd_title = (TextView) convertView.findViewById(R.id.tv_sqhd_title);
            holder.tv_sqhd_time = (TextView) convertView.findViewById(R.id.tv_sqhd_time);
            holder.tv_sqhd_content = (TextView) convertView.findViewById(R.id.tv_sqhd_content);

            convertView.setTag(holder);
        }else{
            holder = (ViewHolder) convertView.getTag();
        }
        SheQu sheQu=list.get(position);

        Picasso.with(context).load(sheQu.getPicpath()).error(R.drawable.no_pic).placeholder(R.drawable.loading).into(holder.iv_sqhd);

        holder.tv_sqhd_title.setText(list.get(position).getTitle());
        holder.tv_sqhd_time.setText(list.get(position).getTime());
        holder.tv_sqhd_content.setText(list.get(position).getContent());
        return convertView;
    }
    class ViewHolder{
        private ImageView iv_sqhd;
        private TextView tv_sqhd_title,tv_sqhd_time,tv_sqhd_content;
    }
    public List<SheQu> setListData(List<SheQu> list){
        return this.list=list;
    }
}
